package com.zues.thread.create.pool;

import com.zues.thread.util.ThreadUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

/**
 * 测试线程池的submit方法
 * submit方法有返回值
 * @ClassName TestSubmit
 * @Description TODO
 * @Author zeus
 * @Date 3/21/2025 4:24 下午
 * @Version 1.0
 **/
@Slf4j(topic = "c.TestSubmit")
public class TestSubmit {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService pool = Executors.newFixedThreadPool(2);

        Future<String> future = pool.submit(() -> {
            log.debug("running...");
            ThreadUtil.sleep(1);
            return "ok";
        });
        log.debug("{}",future.get());
        pool.shutdown();
    }

}
